#include<iostream>
#include<algorithm>
#include<ctime>
#include<iterator>
using namespace std;
bool LessThan4(int n){return n<4;}
int main()
{
	ostream_iterator<int>oit(cout,",");
	int a[5] = {1,2,3,4,5};
	reverse(a,a+5);
	cout<<"1) ";copy(a,a+5,oit);cout<<endl;
	int b[5] = {0,0,0,0,0};
	reverse_copy(a,a+5,b);
	cout<<"2) ";copy(b,b+5,oit);cout<<endl;
	cout<<"3) ";copy(a,a+5,oit);cout<<endl;
	bool result = prev_permutation(a,a+5);
	cout<<"4) ";copy(a,a+5,oit);cout<<endl;
	result = next_permutation(a,a+5);
	cout<<"5) ";copy(a,a+5,oit);cout<<endl;
	result = next_permutation(a,a+5);
	cout<<"6) "<<result<<endl;
	srand(time(0));
	random_shuffle(a,a+5);
	cout<<"7) ";copy(a,a+5,oit);cout<<endl;
	partition(a,a+5,LessThan4);
	cout<<"8) ";copy(a,a+5,oit);cout<<endl;
	random_shuffle(a,a+5);
	cout<<"9) ";copy(a,a+5,oit);cout<<endl;
	stable_partition(a,a+5,LessThan4);
	cout<<"10) ";copy(a,a+5,oit);cout<<endl;
	return 0;
}